// pages/voiceActor/voiceactor.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    animateHeader:{},
    layerShow:true,
    leftCon:['智能排序','七日榜单'],
    orderInner:'智能排序',
    activeNum:'0 ',
    firstNum:'0',
    secondNum:'0',
    thirdNum:'0'

  },
  onLoad: function (options) {
    console.log(options)
    this.setData({
      stypeId: options.stype_id,
      sortby:1,
      sexId: 0,
      profieId:0,
      voiceTag:0
    })
    var that=this;
    var common = require('../../../utils/common');
    common.HttpRequst(true, 'commend/sift_list&sortby=1', 2, '', '', 'get', false, function setting(dataCon) {
      that.setData({
        rightCon: dataCon.data
      });
      console.log(dataCon.data)
    });
    common.HttpRequst(true, 'commend/one_category_list&stype_id=' + that.data.stypeId + '&sortby=' + that.data.sortby + '&sex_id=' + that.data.sexId + '&profie_id=' + that.data.profieId + '&voice_tag=' + that.data.voiceTag , 2, '', '', 'get', false, function setting(dataCon) {
      that.setData({
        categoryList: dataCon.data
      });
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.animateHeader=wx.createAnimation({
      duration:500,
      timingFunction:'ease',
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  /**
   * 状态栏点击事件
   */
  animateActive: function (event) {
    var that = this;
    console.log(event)
    var dataset = event.currentTarget.dataset;
    if (dataset.layer) {
      that.animateHeader.top(42).step();
      that.setData({
        animateHeader: that.animateHeader.export(),
        layerShow: (dataset.layer == 1) ? true : false
      })     
    } else {
      that.animateHeader.top(-200).step();
      if (dataset.inner) {
        that.setData({
          animateHeader: that.animateHeader.export(),
          orderInner: dataset.inner,
          activeNum: dataset.index
        })
      } else {
        console.log("x")
        var that = this;
        var common = require('../../../utils/common');
        that.setData({
          animateHeader: that.animateHeader.export(),
          firstNum: (typeof (dataset.firstIndex) === 'number') ? dataset.firstIndex : that.data.firstNum,
          secondNum: (typeof (dataset.secondIndex) === 'number') ? dataset.secondIndex : that.data.secondNum,
          thirdNum: (typeof (dataset.thirdIndex) === 'number') ? dataset.thirdIndex : that.data.thirdNum
        });
        if (dataset.sex){
          that.setData({
            sexId: dataset.sex
          })
        } else if (dataset.profile){
          that.setData({
            profieId: dataset.profile
          })
        } else if (dataset.voice){
          that.setData({
            voiceTag: dataset.voice
          })
        }
        common.HttpRequst(true, 'commend/one_category_list&stype_id=' + that.data.stypeId + '&sortby=' + that.data.sortby + '&sex_id=' + that.data.sexId + '&profie_id=' + that.data.profieId + '&voice_tag=' + that.data.voiceTag, 2, '', '', 'get', false, function setting(dataCon) {
          that.setData({
            categoryList: dataCon.data
          });
        });
      }

    }

  },
  toDetail: function (e) {
    wx.navigateTo({
      url: '../detail/detail?id=' + e.currentTarget.dataset.id,
    })
  }
})